package com.group.project.hrms.service.impl;

import com.group.project.hrms.entity.SpecialCheckDate;
import com.group.project.hrms.mapper.SpecialCheckDateMapper;
import com.group.project.hrms.service.ISpecialCheckDateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class SpecialCheckDateService implements ISpecialCheckDateService {

    @Autowired
    private SpecialCheckDateMapper specialCheckDateMapper;

    @Override
    public int insertSpecialCheckDate(SpecialCheckDate specialCheckDate) {
        return specialCheckDateMapper.insert(specialCheckDate);
    }

    @Override
    public int deleteSpecialCheckDate(SpecialCheckDate specialCheckDate) {
        return specialCheckDateMapper.deleteByPrimaryKey(specialCheckDate);
    }

    @Override
    public int updateSpecialCheckDate(SpecialCheckDate specialCheckDate) {
        return specialCheckDateMapper.updateByPrimaryKey(specialCheckDate);
    }

    @Override
    public SpecialCheckDate selectOneSpecialCheckDate(SpecialCheckDate specialCheckDate) {
        return specialCheckDateMapper.selectByPrimaryKey(specialCheckDate);
    }

    @Override
    public SpecialCheckDate selectOneSpecialCheckDateBySpID(String sid) {
        Example example = new Example(SpecialCheckDate.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.orEqualTo("specialCheckId" , sid);
        return specialCheckDateMapper.selectOneByExample(example);
    }

    @Override
    public List<SpecialCheckDate> selectSpecialCheckDateBySPMonth(String month) {
        Example example = new Example(SpecialCheckDate.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.orLike("specialDate" , "%" + month + "%");
        return specialCheckDateMapper.selectByExample(example);
    }

    @Override
    public List<SpecialCheckDate> selectAllSpecialCheckDate() {
        return specialCheckDateMapper.selectAll();
    }
}
